#ifndef MDTX_USE_RCPPARMADILLO
#define MDTX_USE_RCPPARMADILLO
#endif

#include <RcppArmadillo.h>
using namespace Rcpp;

#include "mdtx-online/indicator/indicator_type_s2_cov.h"
using namespace mdtx::online;

#include "indi_common.h"

using rollcov_ = indi1<indicator::rollcov>;

//' Moving covariance
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollcov(NumericVector x, NumericVector y, int period)
{
    auto c = rollcov_::create_t(period);
    return rollcov_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollcov_new(int period)
{
    return rollcov_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector rollcov_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollcov_::run(ptr, x, y);
}

using rollcov_ew_ = indi1<indicator::rollcov_ew>;

//' Exponentially weighted covariance
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollcov_ew(NumericVector x, NumericVector y, int period)
{
    auto c = rollcov_ew_::create_t(period);
    return rollcov_ew_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollcov_ew_new(int period)
{
    return rollcov_ew_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector rollcov_ew_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollcov_ew_::run(ptr, x, y);
}

using rollcov_cu_ = indi1<indicator::rollcov_cu>;

//' Cumulative covariance
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollcov_cu(NumericVector x, NumericVector y)
{
    auto c = rollcov_cu_::create_t();
    return rollcov_cu_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollcov_cu_new()
{
    return rollcov_cu_::create();
}

// [[Rcpp::export(rng = false)]]
NumericVector rollcov_cu_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollcov_cu_::run(ptr, x, y);
}

using rollcorr_ = indi1<indicator::rollcorr>;

//' Moving correlation
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollcorr(NumericVector x, NumericVector y, int period)
{
    auto c = rollcorr_::create_t(period);
    return rollcorr_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollcorr_new(int period)
{
    return rollcorr_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector rollcorr_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollcorr_::run(ptr, x, y);
}

using rollcorr_ew_ = indi1<indicator::rollcorr_ew>;

//' Exponentially weighted correlation
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollcorr_ew(NumericVector x, NumericVector y, int period)
{
    auto c = rollcorr_ew_::create_t(period);
    return rollcorr_ew_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollcorr_ew_new(int period)
{
    return rollcorr_ew_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector rollcorr_ew_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollcorr_ew_::run(ptr, x, y);
}

using rollcorr_cu_ = indi1<indicator::rollcorr_cu>;

//' Cumulative correlation
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollcorr_cu(NumericVector x, NumericVector y)
{
    auto c = rollcorr_cu_::create_t();
    return rollcorr_cu_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollcorr_cu_new()
{
    return rollcorr_cu_::create();
}

// [[Rcpp::export(rng = false)]]
NumericVector rollcorr_cu_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollcorr_cu_::run(ptr, x, y);
}

using rollbeta_ = indi1<indicator::rollbeta>;

//' Moving linear regression beta
//'
//' @param x Numeric vector Independent variable x
//' @param y Numeric vector Dependent variable y
//' @param period Period of rolling window
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollbeta(NumericVector x, NumericVector y, int period)
{
    auto c = rollbeta_::create_t(period);
    return rollbeta_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollbeta_new(int period)
{
    return rollbeta_::create(period);
}

// [[Rcpp::export(rng = false)]]
NumericVector rollbeta_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollbeta_::run(ptr, x, y);
}

using rollbeta_cu_ = indi1<indicator::rollbeta_cu>;

//' Cumulative beta
//'
//' @param x Numeric vector Variable x
//' @param y Numeric vector Variable y
//' @return Numeric vector
//' @export
// [[Rcpp::export(rng = false)]]
NumericVector rollbeta_cu(NumericVector x, NumericVector y)
{
    auto c = rollbeta_cu_::create_t();
    return rollbeta_cu_::run_t(c, x, y);
}

// [[Rcpp::export(rng = false)]]
SEXP rollbeta_cu_new()
{
    return rollbeta_cu_::create();
}

// [[Rcpp::export(rng = false)]]
NumericVector rollbeta_cu_run(SEXP ptr, NumericVector x, NumericVector y)
{
    return rollbeta_cu_::run(ptr, x, y);
}
